
function selectWarehouse(storehouse_id){
	var url = '/storage/admin/pages/warehouse.do?method=selectWarehouse&d=' + new Date();
	url = url + '&storehouse_id='+storehouse_id;
	
	$.getJSON(url, {}, function(data){
		var storehouse_id = document.getElementById('storehouse_id');
		var storehouse_name = document.getElementById('storehouse_name');
		var employee_id = document.getElementById('employee_id');
		var storehouse_phone = document.getElementById('storehouse_phone');
		var storehouse_add = document.getElementById('storehouse_add');
		var storehouse_memo = document.getElementById('storehouse_memo');

		setTimeout(function (){
			storehouse_id.value = data[0][0];
			storehouse_name.value = data[0][1];
			employee_id.value = data[0][6];
			storehouse_phone.value = data[0][3];
			storehouse_add.value = data[0][4];
			storehouse_memo.value = data[0][5];
		},500);
	});
};
function saveOrUpdate(){
	var storehouse_id_val = escape(escape(document.getElementById('storehouse_id').value));
	
	var storehouse_name = escape(escape(document.getElementById('storehouse_name').value));
	var employee_id = escape(escape(document.getElementById('employee_id').value));
	var storehouse_phone = escape(escape(document.getElementById('storehouse_phone').value));
	
	var isFull = ''!=storehouse_name&&''!=employee_id&&''!=storehouse_phone;
	
	if(isFull){
		storehouse_id_val==''?save():update();
	}else{
		alert('必要信息不完整');
	}
};
function save(){
	var storehouse_name = escape(escape(document.getElementById('storehouse_name').value));
	var employee_id = escape(escape(document.getElementById('employee_id').value));
	var storehouse_phone = escape(escape(document.getElementById('storehouse_phone').value));
	var storehouse_add = escape(escape(document.getElementById('storehouse_add').value));
	var storehouse_memo = escape(escape(document.getElementById('storehouse_memo').value));

	var url = '/storage/admin/pages/warehouse.do?method=create&d=' + new Date();
	url = url + '&storehouse_name='+storehouse_name;
	url = url + '&employee_id='+employee_id;
	url = url + '&storehouse_phone='+storehouse_phone;
	url = url + '&storehouse_add='+storehouse_add;
	url = url + '&storehouse_memo='+storehouse_memo;
	
	$.getJSON(url, {}, function(data){
		if(data=="true"){
			alert("保存成功");
			window.close();
		}else{
			alert("证件号码已经使用过了");
		}
	});
};
function update(){
	var storehouse_id = escape(escape(document.getElementById('storehouse_id').value));
	var storehouse_name = escape(escape(document.getElementById('storehouse_name').value));
	var employee_id = escape(escape(document.getElementById('employee_id').value));
	var storehouse_phone = escape(escape(document.getElementById('storehouse_phone').value));
	var storehouse_add = escape(escape(document.getElementById('storehouse_add').value));
	var storehouse_memo = escape(escape(document.getElementById('storehouse_memo').value));

	var url = '/storage/admin/pages/warehouse.do?method=update&d=' + new Date();
	url = url + '&storehouse_id='+storehouse_id;
	url = url + '&storehouse_name='+storehouse_name;
	url = url + '&employee_id='+employee_id;
	url = url + '&storehouse_phone='+storehouse_phone;
	url = url + '&storehouse_add='+storehouse_add;
	url = url + '&storehouse_memo='+storehouse_memo;
	
	$.getJSON(url, {}, function(data){
		if(data=="true"){
			alert("保存成功");
			window.close();
		}else{
			alert("保存失败");
		}
	});
};